package lesson3.pages;

import lesson3.api.ApplicationManager;
import lesson3.api.models.UserModel;
import lesson3.pages.locators.page.RegistrationPageLocators;

public class RegistrationPage extends PageBase
{
	private final RegistrationPageLocators locators;

	public RegistrationPage(ApplicationManager p_app)
	{
		super(p_app);
		locators = new RegistrationPageLocators(p_app);
	}

	private void fillRegData(UserModel p_userData)
	{
		// Fill registration data
		type(locators.txtLogin(), p_userData.login);
		type(locators.txtPassword(), p_userData.password);
		type(locators.txtPasswordConfirm(), p_userData.password);
		type(locators.txtFirstNname(), p_userData.firstName);
		type(locators.txtLastName(), p_userData.lastName);
		type(locators.txtEmail(), p_userData.email);
		type(locators.txtSkype(), p_userData.skypeName);
		type(locators.txtPhone(), p_userData.phone);
		type(locators.txtDepartment(), p_userData.department);
		type(locators.txtOccupation(), p_userData.occupation);
		selectByValue(locators.selectLanguage(), p_userData.language);
	}

	private void submitRegData()
	{
		// Submit registration data
		click(locators.btnRegistration());
	}

	public void register(UserModel p_userData)
	{
		fillRegData(p_userData);
		submitRegData();
	}
}
